<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>练习background-clip</title>
  <style>
    /* 
      background-postion 
      规定背景图片位置
      1. px 第一值是宽度，第二个是高度，如果只设置第一个，第二个默认是auto
      2. 百分比，根据相对于父元素
      3. cover 把图像扩展至足够大，以使背景完全覆盖背景区域。背景图像的某些部分会无法显示(保持等比比例)
      4. contain 吧图片扩展到最大尺寸，使宽度和高度完全适应区域(保持等比比例)会使背景区域一部分为空白
     */
  .bg{
    background: url('../../img/a.png') no-repeat;
    width: 400px;
    height: 140px;
    /* height: auto; */
    padding: 40px;
    display: inline-block;
    margin-right: 20px;
    border: 2px solid #ccc;
  }
  .bgImg1 {
    background-origin: padding-box;
    background-position: 20px 20px;
    margin-bottom: 20px;
    /* background-clip: content-box; */
    /* background-size: 100% 100%; */
    /* background-size: cover; */

  }
  .bgImg2 {
    /* background-clip: padding-box; */
    background: url('../../img/a.png') no-repeat;
    background-position: 20% 10%;
    background-origin: content-box;
    margin-bottom: 20px;
    width: 400px;
    height: 140px;
    padding: 40px;
  }
  .bgImg3 {
    background-origin: content-box;
    background: url('../../img/a.png') no-repeat;
    background-position: cover;
  }
  .bgImg4 {
    background-position: contain;
    background: url('../../img/ab.png') no-repeat;
  }
  .img_P {
    width: auto;
    height: auto;
    border: 2px solid skyblue;
  }
  </style>
</head>
<body>
  <div class="bg bgImg1"></div>
  <div class="img_P"><div class="bgImg2"></div></div>
  <div class="bg bgImg3"></div>
  <div class="bg bgImg4"></div>
</body>
</html>